package com.chhuang.icoolvideo;

import java.io.File;
import java.io.IOException;

import org.apache.http.client.ClientProtocolException;

import com.chhuang.utils.Assert;
import com.chhuang.utils.httpRequest.HttpClientUtil;

public class DownloadVideoThread implements Runnable{
	
	private Video video;
	
	public DownloadVideoThread(Video video){
		this.video = video;
	}

	public void run() {
		if(Assert.isInvalidString(video.getDownloadUrl())){
			return ;
		}
		try {
			HttpClientUtil.download(video.getDownloadUrl(), new File(App.BASE_FILE_DIR+video.getVideoName()+App.VIDEO_SUFFIX), null);
		} catch (ClientProtocolException e) {
			// TODO Auto-generated catch block
			System.out.println(video.toString());
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			System.out.println(video.toString());
			e.printStackTrace();
		}
	}

}
